<%@ page language="java" import="java.util.*,com.chj.entity.*"  pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE>
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>个人中心</title>
<link href="css/bootstrap.min.css"rel="stylesheet" type="text/css">
<link href="css/evtcar.css" rel="stylesheet" type="text/css" />
<link href="css/person/userInf.css" rel="stylesheet" type="text/css" />
<link href="css/font-awesome-4.5.0/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link href="css/person/register.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="js/login.js" charset="utf-8"></script>
<script type="text/javascript" src="js/jquery-2.1.3.min.js"></script>
<script type="text/javascript" src="js/staticinfo.js"></script>
<script type="text/javascript" src="js/person/jquery.raty.js" ></script>
<script type="text/javascript" src="js/person/UserCheck.js"></script> 
</head>
<body>
<!--顶部导航栏开始 -->
<%@include file="head.jsp" %>
<!--下面是中部导航栏的代码-->
<div class="nav-green nav-head" id="J_m_nav">
    <div class="nav-content">
        <div class="nav-btn "><a href="index.do">首页</a></div>
        <div class="nav-btn"><a href="ecarcharge/we_need_charge.do">我要充电</a></div>
        <div class="nav-btn active"><a href="person/person_center.do">个人中心</a></div>
        <div class="nav-btn"><a href="about_me.do">关于我们</a></div>
        <div class="nav-btn"><a href="person/person_help.do">用户帮助</a></div>
    </div>
</div>
</header>
<!--顶部导航栏结束 -->
<div class="main">
    <div class="newcontainer">
        <div id="user-card">
            <div class="inners clearfix without-side">
                <div class="head-line"><div class="name"><%=user.getUserName() %></div></div>
                <div class="user-inf">
                    <ul class="introduction">
                        <li><i class="fa fa-phone-square" style="font-size: 20px;"></i><%=user.getUserPhone() %></li><br/>
                        <li><i class="fa fa-file-text"  style="font-size: 20px;"></i><%=user.getUserEmail()%></li>
                    </ul>
                </div>
                <div class="bindings"> 
                    <div class="fast-item">
                            <a href="person/person_msg.do" class="btn">
                                    <div class="img"><i class="fa fa-calendar fa-3x"></i></div>消息提醒
                            </a>
                            <a href="person/person_order_manager.do" class="btn">
                                    <div class="img">   <i class="fa fa-shopping-cart fa-3x"></i></div>订单管理
                            </a>
                            <a href="person/person_ecar.do" class="btn">
                                    <div class="img"><i class="fa fa-desktop fa-3x"></i></div>我的电动汽车                                    </a>
                            </a>
                            <a href="person/person_update.do" class="btn without-side">
                                    <div class="img"><i class="fa fa-info-circle fa-3x"></i></div>我的资料
                            </a>
                    </div>
                </div>
            </div>
        </div>
        <div id="myecar">
            <div class="title">
                    电动汽车管理
                </div>
                <div class="inf">
                    <div class="containbox">
                        <div class="bar">
                            <div role="tabpanel">
                                <!-- Nav tabs -->
                                <ul class="nav nav-tabs" role="tablist" id="myTab">
                                    <li role="presentation" class="active">
                                        <a href="#neworder" aria-controls="neworder" role="tab"
                                            data-toggle="tab">我的电动汽车</a>
                                    </li>
                                    <li role="presentation">
                                        <a href="#oldorder" aria-controls="oldorder" role="tab"
                                            data-toggle="tab">添加电动汽车</a>
                                    </li>
                                </ul>

                                <!-- Tab panes -->
                                <div class="tab-content">
                                    <div role="tabpanel" class="tab-pane active" id="neworder">
                                        <table class="table table-striped" id="newOrderContent">
                                        <tr>
                                            <th>
                                                电动汽车Id
                                            </th>
                                            <th>
                                                电动汽车名字
                                            </th>
                                            <th>
                                                电动汽车充电时间
                                            </th>
                                            <th>
                                                电动汽车描述
                                            </th>
                                            <th>
                                                电动汽车类型
                                            </th>
                                            <th>当前电动汽车状态</th>
                                            <th>
                                                操作
                                            </th>
                                        </tr>
                                        </table>
                                    </div>

                                    <div role="tabpanel" class="tab-pane" id="oldorder">
                                        <table class="table table-striped" id="oldOrderContent">
                                            <tr>
                                                <td class="t"><span>*</span>电动车车牌：</td>
                                                <td><input type="text" id="ecarId" value="" autocomplete="off"></td>
                                            </tr>
                                            <tr>
                                                <td class="t"><span>*</span>电动车名称：</td>
                                                <td><input type="text" id="ecarName" value="" autocomplete="off"></td>
                                            </tr>
                                            <tr>
                                                <td class="t"><span>*</span>电动车充电时间：</td>
                                                <td><input type="text" id="ecarTime" value="" autocomplete="off"></td>
                                            </tr>
                                            <tr>
                                                <td class="t">电动汽车类型：</td>
                                                <td>
                                                <!-- 下拉框 -->
                                                <input type="text" id="ecarType" value="" autocomplete="off"></td>
                                            </tr>
                                            <tr>
                                                <td class="t">电动汽车描述</td>
                                                <td><textarea rows="3" cols="50" type="text" id="ecarDescription" value="" autocomplete="off"></textarea></td>
                                            </tr>
                                            <tr>
                                                <td class="t">
                                                    &nbsp;
                                                </td>
                                                <td>
                                                    <input type="submit" id="saveecar" style="background: -webkit-linear-gradient(#75abda,#6698c9);width: 68px;  height: 34px;color: #fff;" value="保存信息">
                                                    <span id="SaveOkMsg" style="display: none;"> 你的资料保存成功！ </span>
                                                </td>
                                            </tr>
                                            
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>  
        </div>
    </div>
</div>
<%@include file="footer.jsp" %>
</form>
</body>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->

<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
</html>

</html>
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"电动汽车智能充电服务系统，想充就充，一键直达！","bdMini":"2","bdMiniList":false,"bdPic":"www.ezchong.com/pic/index-img1.png;www.ezchong.com/pic/index-img2.png;www.ezchong.com/pic/index-img3.png;","bdStyle":"0","bdSize":"16"},"slide":{"type":"slide","bdImg":"6","bdPos":"right","bdTop":"238.5"},"image":{"viewList":["weixin","tsina","qzone","tqq","renren","isohu"],"viewText":"分享到：","viewSize":"16"},"selectShare":{"bdContainerClass":null,"bdSelectMiniList":["weixin","tsina","qzone","tqq","renren","isohu"]}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "//hm.baidu.com/hm.js?c8b733648de5ad25d37a909cd546fbe3";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>
        
    </div>


    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
   
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>

    <script type="text/javascript">

        $('#myTab a').click(function (e) {
            e.preventDefault()
            $(this).tab('show')
        })

        
        $(function(){

            $.ajax({
                type: "POST",
                dataType: "json",
                url: 'person/get_person_ecar.do',
                success: function (data) {

                    var eCarModelList = data.eCarModelList;

                    $.each(eCarModelList, function(i, content){
                        var html  = '<tr align="center">';
                            html += '<td>'+eCarModelList[i].eCar.ecarId+'</td>';
                            html += '<td>'+eCarModelList[i].eCar.ecarName+'</td>';
                            html += '<td>'+eCarModelList[i].eCar.ecarTime+'（小时）</td>';
                            html += '<td>'+eCarModelList[i].eCar.ecarDescription+'</td>';
                            if (eCarModelList[i].eCar.ecarType == 1) {
                                html += '<td>普通</td>';
                            } else {
                                html += '<td>特殊</td>';
                            }
                            html += '<td>'+eCarModelList[i].eCarStatu+'</td>';
                            var ecarPk = eCarModelList[i].eCar.ecarPk;
                            if (eCarModelList[i].eCarStatu != '充电中'){
                                html += "<td><button class=\"btn btn-primary\" onclick=\"confirmDelButton("+"'"+ecarPk+"'"+")\">删除</button></td>";
                            } else {
                            	html += "<td></td>";
                            }
                            html += '</tr>';
                        $("#newOrderContent").append(html);
                    });
                },
                error: function(data) {
                    alert(data.responseText);
                 }
            });
        });
        
        $('#saveecar').click(function(){

            var ecarId          = $('#ecarId').val();
            var ecarName        = $('#ecarName').val();
            var ecarTime        = $('#ecarTime').val();
            var ecarType        = $('#ecarType').val();
            var ecarDescription = $('#ecarDescription').val();

            $.ajax({
                        type: "POST",
                        dataType: "json",
                        url: 'person/add_person_ecar.do',
                        data: {
                            ecarId : ecarId,
                            ecarName : ecarName,
                            ecarTime : ecarTime,
                            ecarType : ecarType,
                            ecarDescription : ecarDescription
                        },
                        success: function (result) {
                            
                            if(result.flg=="true"){
                                //提交成功
                                alert('提交成功！');
                                window.location.href = 'person/person_ecar.do';
                            }else { 
                               //提交失败
                                alert(result.errorMsg);
                            }
                         },
                         error: function(result) {
                                alert(result.errorMsg);
                         }
                    });
            });

         function confirmDelButton(url){
            if (confirm('确定删除吗？')) {

                var ajax_utl = 'person/delete_person_ecar/'+url+'.do';
                $.ajax({
	                type: "POST",
	                dataType: "json",
	                url: ajax_utl,
	                success: function (result) {
	
	                    if(result.flg=="true"){
	                        //提交成功
	                        alert('删除成功！');
	                        window.location.href = 'person/person_ecar.do';
	                    }else { 
	                       //提交失败
	                        alert(result.errorMsg);
	                    }
	                },
	                error: function(data) {
	                    alert(data.responseText);
	                 }
	            });
           }
        }
    </script>

